{% extends "base.html" %}

{% block title %}| Rank{% endblock %}

{% block body %}

<center>
	<h2> Rank Geral / <a href="/rank/raridade"> Rank por Raridade </a> / <a href="/rank/semanal"> Rank Semanal </a> <div style="font-size:0.5em">({{users.paginator.count}} membros)</div></h2>
</center>

<div class="pagination" align="center">
    <span class="step-links" >
        {% if users.has_previous %}
            <a href="?page=1"><<</a>
            <a href="?page={{ users.previous_page_number }}"><</a>
        {% endif %}

        <span class="current">
            {{ users.number }} de {{ users.paginator.num_pages }}
        </span>

        {% if users.has_next %}
            <a href="?page={{ users.next_page_number }}">></a>
            <a href="?page={{ users.paginator.num_pages }}">>></a>
        {% endif %}
		  <h5>{{ users.start_index }} - {{ users.end_index }}</h5>
			
    </span>
</div>
<table class="sortable" align="center">
        <tr height=35> 
                <th class="righttop"> Rank </th>
                <th align="center" style="border-left: 0px"> <img src="../../media/up.png" > </th>
                <th align="center" > Nome </th>
                <th class="righttop"> <img src="../../media/level.png"> </th>
                <th class="lefttop">  <img src="../../media/up.png" > </th>
                <th align="center" width=100 > % </th>
                <th class="righttop"> <img src="../../media/platinum.png" height=20 >     </th>
                <th class="lefttop">  <img src="../../media/up.png" > </th>
                <th class="righttop"> <img src="../../media/gold.png" height=20>     </th>
                <th class="lefttop">  <img src="../../media/up.png" > </th>
                <th class="righttop"> <img src="../../media/silver.png" height=20>   </th>
                <th class="lefttop">  <img src="../../media/up.png" > </th>
                <th class="righttop"> <img src="../../media/bronze.png" height=20>   </th>
                <th class="lefttop">  <img src="../../media/up.png" > </th>
                <th class="righttop"> <img src="../../media/total.png" height=20 ></th>
                <th class="lefttop">  <img src="../../media/up.png" > </th>
                <th class="righttop"> Pontos   </th>
                <th class="lefttop">  <img src="../../media/up.png" > </th>
        </tr>
{% for user_rank, dif in users.object_list %}
        <tr 
					{% ifequal user_rank.user.auth.username request.user.username %}
						style="background:#110011"
					{% endifequal  %} > 

                <td class="right">{{ user_rank.rank }} </td>
                <td class="left"> 
					{% if user_rank.last_trophy.rank %}
						{% if dif %}
							+{{ user_rank.last_trophy.rank }}
						{% else %}
							<div style="color:red">{{ user_rank.last_trophy.rank }}</div>
						{% endif %}
					{%endif %}
					</td>
                <td align="left" style="border-right:0px">
                        <img class="meio" src="{{ user_rank.user.pic_url}}" height=20 />
                        <a href= "{{ user_rank.user.auth.username }}"> {{ user_rank.user.auth.username}} </a>
                </td>
                <td class="right">{{ user_rank.level }} </td>
                <td class="left"> {% if user_rank.last_trophy.level %} {{ user_rank.last_trophy.left }} {%endif %} </td>
                <td align="left"   style="border-right: 0px">
                           <div class="barslide" style="width: {{user_rank.perc_level}}px">
                                <div class="barbg"> {{ user_rank.perc_level }}% </div></div>
                </td>

                <td class="right">{{ user_rank.platinum}}</td>
                <td class="left"> {% if user_rank.last_trophy.platinum%} +{{ user_rank.last_trophy.platinum}} {%endif %} </td>
                <td class="right">{{ user_rank.gold}}</td>
                <td class="left"> {% if user_rank.last_trophy.gold %}    +{{ user_rank.last_trophy.gold }} {%endif %} </td>
                <td class="right">{{ user_rank.silver}}</td>
                <td class="left"> {% if user_rank.last_trophy.silver %}  +{{ user_rank.last_trophy.silver}} {%endif %} </td>
                <td class="right">{{ user_rank.bronze}}</td>
                <td class="left"> {% if user_rank.last_trophy.bronze %}  +{{ user_rank.last_trophy.bronze }} {%endif %} </td>
                <td class="right">{{ user_rank.total }}</td>
                <td class="left"> {% if user_rank.last_trophy.total %}   +{{ user_rank.last_trophy.total }} {%endif %} </td>
                <td class="right">{{ user_rank.points }}</td>
                <td class="left"> {% if user_rank.last_trophy.points %}  +{{ user_rank.last_trophy.points }} {%endif %} </td>
        </tr>
{% endfor %}

</table>
<br/>
<div class="pagination" align="center">
    <span class="step-links" >
        {% if users.has_previous %}
            <a href="?page={{ users.previous_page_number }}"><</a>
        {% endif %}

        <span class="current">
            {{ users.number }} de {{ users.paginator.num_pages }}
        </span>

        {% if users.has_next %}
            <a href="?page={{ users.next_page_number }}">></a>
        {% endif %}
    </span>
</div>
<br/>

{% if new_users %}
        <table class="sortable" align="center">
                <th colspan=10>
                        Novos Usuarios
                </th>
                <tr height=35> 
                        <th align="center" > Nome </th>
                        <th class="righttop"> <img src="../../media/level.png"> </th>
                        <th align="center" width=100 > % </th>
                        <th class="righttop"> <img src="../../media/platinum.png" height=20>     </th>
                        <th class="righttop"> <img src="../../media/gold.png"     height=20>     </th>
                        <th class="righttop"> <img src="../../media/silver.png"   height=20>   </th>
                        <th class="righttop"> <img src="../../media/bronze.png"   height=20>   </th>
                        <th class="righttop"> <img src="../../media/total.png"    height=20 ></th>
                        <th class="righttop"> Pontos   </th>
                </tr>

        {% for user_rank in new_users %}
                <tr> 
                        <td align="left" style="border-right:0px">
                                <img align="center" src="{{ user_rank.user.pic_url}}" height=20 />
                                <a href= "{{ user_rank.user.auth.username }}"> {{ user_rank.user.auth.username}} </a>
                        </td>
                        <td align="center">{{ user_rank.level }} </td>
                        <td align="left"   style="border-right: 0px">
                                        <div class="barslide" style="width: {{user_rank.perc_level}}px">
                                        <div class="barbg"> {{ user_rank.perc_level }}% </div></div>
                        </td>
                 
                        <td align="center">{{ user_rank.platinum}}</td>
                        <td align="center">{{ user_rank.gold}}</td>
                        <td align="center">{{ user_rank.silver}}</td>
                        <td align="center">{{ user_rank.bronze}}</td>
                        <td align="center">{{ user_rank.total }}</td>
                        <td align="center">{{ user_rank.points }}</td>
                </tr>
        {% endfor %}
        </table>
{% endif %}
{% endblock %}
